package top.humbleyuan.test;

import java.math.BigDecimal;
import java.util.Scanner;

/**
 * @Author HumbleYuan
 * @Date 2020/4/1 18:44
 * @Des
 */
public class XieChengExamDemo {
    public static void main(String[] args) {
        e1();
        //e3();

        //e2();
    }

    private static void e2() {
        Scanner in = new Scanner(System.in);
        long res;

        int _n;
        _n = Integer.parseInt(in.nextLine().trim());

        int _m;
        _m = Integer.parseInt(in.nextLine().trim());

        int _birthYear_size = 0;
        _birthYear_size = Integer.parseInt(in.nextLine().trim());
        int[] _birthYear = new int[_birthYear_size];
        int _birthYear_item;
        for(int _birthYear_i = 0; _birthYear_i < _birthYear_size; _birthYear_i++) {
            _birthYear_item = Integer.parseInt(in.nextLine().trim());
            _birthYear[_birthYear_i] = _birthYear_item;
        }

        int _x;
        _x = Integer.parseInt(in.nextLine().trim());

        res = countDolphin(_n, _m, _birthYear, _x);
        System.out.println(String.valueOf(res));
    }

    private static int countDolphin(int n, int m, int[] birthYear, int x){

        return 1;
    }

    private static void e3() {
        Scanner sc = new Scanner(System.in);
        String[] strs = {"surprise", "happy", "ctrip", "travel", "wellcome","student","system","program","editor"};

        while(sc.hasNext()) {
            String s = sc.nextLine();

            String res = null;
            if(s == null || s.length() < 3 || s.length() > 10) {
                System.out.println(res);
                continue;
            }

            int i;
            for (i = 0; i < strs.length; i++) {
                int dis = dis(s, strs[i]);
                if(dis <= 2) {
                    System.out.println(strs[i]);
                    break;
                }
            }


            if(i == strs.length) {
                System.out.println(res);
            }

        }

        sc.close();
    }

    // 计算距离
    public static int dis(String s1, String s2) {
        int[][] dis = new int[s1.length() + 1][s2.length() + 1];

        // 初始化边界值
        for (int i = 1; i <= s1.length(); i++) {
            dis[i][0] = i;
        }

        for (int i = 1; i <= s2.length(); i++) {
            dis[0][i] = i;
        }

        // 以列为外层循环
        for (int i = 1; i <= s1.length(); i++) {
            for (int j = 1; j <= s2.length(); j++) {
                int replaceDis = 1;
                // 字符相同
                if(s1.charAt(i-1) == s2.charAt(j-1)) {
                    replaceDis = 0;
                }

                dis[i][j] = Math.min(dis[i-1][j-1] + replaceDis,
                        Math.min(dis[i-1][j], dis[i][j-1]) + 1);
            }
        }

        // 只算距离
        return dis[s1.length()][s2.length()];
    }

    private static void e1() {
        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            int num = Integer.valueOf(sc.nextLine());

            int[][] t = new int[num][2];
            for (int i = 0; i < num; i++) {
                String s = sc.nextLine();
                t[i][0] = Integer.valueOf(s.split(",")[0]);
                t[i][1] = Integer.valueOf(s.split(",")[1]);
            }

            int work = 0;

            boolean[] p = new boolean[num];

            for (int i = 0; i < num; i++) {
                if(i == 0) {
                    work++;
                    continue;
                }

                for (int j = 0; j < i; j++) {
                    if(t[i][0] >= t[j][1] && !p[j]) {

                        // 找到一个空闲的人
                        t[j][0] = t[i][0];
                        t[j][1] = t[i][1];
                        p[j] = true;
                        work--;
                        break;
                    }
                }

                work++;
            }

            System.out.println(work);





        }


        sc.close();
    }
}
